// 认证相关的 Mock 数据

// 测试用户账号信息
export const TEST_ACCOUNTS = {
  PHONE: '123456',
  PASSWORD: '123456',
  VERIFICATION_CODE: '123456'
};

// 模拟登录成功返回的用户数据
export const mockUserData = {
  token: 'mock_jwt_token_' + Date.now(),
  refreshToken: 'mock_refresh_token_' + Date.now(),
  user: {
    id: 1,
    phone: TEST_ACCOUNTS.PHONE,
    name: '张三',
    avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=123456',
    role: '患者',
    department: '内科',
    email: 'zhangsan@example.com',
    lastLoginTime: new Date().toISOString()
  }
};

// 模拟登录成功
export const mockLoginSuccess = async () => {
  // 模拟网络请求延迟
  await new Promise(resolve => setTimeout(resolve, 1000));
  
  // 返回模拟的用户数据
  return {
    ...mockUserData,
    token: 'mock_jwt_token_' + Date.now(),
    refreshToken: 'mock_refresh_token_' + Date.now()
  };
};

// 验证登录凭据
export const validateCredentials = (phone: string, password: string, verificationCode?: string) => {
  if (phone === TEST_ACCOUNTS.PHONE) {
    if (password && password === TEST_ACCOUNTS.PASSWORD) {
      return { success: true, type: 'password' };
    }
    if (verificationCode && verificationCode === TEST_ACCOUNTS.VERIFICATION_CODE) {
      return { success: true, type: 'verification' };
    }
  }
  return { success: false, message: '手机号或密码错误' };
};
